<template>
	<div class="oneMainBox">
		
	
		<div class="show">
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<h1 class="myh1555" align="center">{{ article.title }}</h1>
					<div style="margin: 0.3rem 0;float: left">
						<a class="time">创作时间 {{ article.createTime }}</a>
					</div>
				</div>
				<div class="markdown-body" v-html="article.content"></div>
			</el-card>
		</div>
		</div>
</template>

<script>
	import "github-markdown-css/github-markdown.css";
	import {
		getRequest,
		postRequest
	} from "../utils/api";
	import {
		setCookie2,
		getCookie,
		clearCookie
	} from "../utils/cookie";
	import moment from "moment"
	export default {
		data() {
			return {
				id: "",
				article: {
					id: "",
					title: "",
					summary: "",
					content: "",
					eriter: "",
					createTime: "",
				},
			};
		},

		created() {
			const _this = this;
			_this.oneNew();
		},

		methods: {
			//获取文章
			oneNew() {
				const _this = this;
				_this.id = getCookie("currentArticleID");
				getRequest("/article/showOneArticle?id=" + _this.id).then((res) => {
					_this.article.id = res.data.data.id;
					_this.article.title = res.data.data.title;
					_this.article.createTime = _this.changeTime(res.data.data.createTime);
					var MardownIt = require("markdown-it");
					var md = new MardownIt();
					var content = md.render(res.data.data.content);
					_this.article.content = content;
				});
			},
			//返回
			back() {

			},
			//编辑
			editor() {

			},
			//删除
			deleteBlog() {

			},
			//时间戳转时间
			changeTime(time) {
				return moment(new Date(parseInt(time))).format("YYYY-MM-DD");
			},
		},
	};
</script>

<style lang="less" scoped>
	@import '../assets/css/showarticle.css';
</style>
